import React from 'react';
import { Modal, Input, message } from 'antd';

interface CreateTemplateModalProps {
  visible: boolean;
  onCancel: () => void;
  onOk: (name: string) => void;
}

const CreateTemplateModal: React.FC<CreateTemplateModalProps> = ({ visible, onCancel, onOk }) => {
  const [newTemplateName, setNewTemplateName] = React.useState('');

  const handleOk = () => {
    if (!newTemplateName.trim()) {
      message.warning('请输入模版名称');
      return;
    }
    onOk(newTemplateName);
    setNewTemplateName('');
  };

  return (
    <Modal
      title="创建新模版"
      open={visible}
      onOk={handleOk}
      onCancel={() => {
        onCancel();
        setNewTemplateName('');
      }}
      okText="确认"
      cancelText="取消"
    >
      <Input
        placeholder="请输入模版名称"
        value={newTemplateName}
        onChange={(e) => setNewTemplateName(e.target.value)}
        maxLength={20}
      />
    </Modal>
  );
};

export default CreateTemplateModal; 